import request from '@/utils/request'
import type { AttrInfoListParamsModel, AttrListModel } from './model/AttrModel'
enum Api {
  //获取品牌属性管理列表的接口
  getAttrListApi = '/admin/product/attrInfoList',
  //删除一条品牌属性的接口
  delOneAttrListApi = `/admin/product/deleteAttr`,
  //查询一条品牌属性数据的接口
  findOneAttrListDataApi = `/admin/product/getAttrValueList`,
  //添加品牌属性数据的接口
  addAttrListData = `/admin/product/saveAttrInfo`,
}

//请求品牌属性管理列表数据的函数
export const ReqAttrListData = ({
  category1Id,
  category2Id,
  category3Id,
}: AttrInfoListParamsModel) =>
  request.get<any, AttrListModel>(
    `${Api.getAttrListApi}/${category1Id}/${category2Id}/${category3Id}`
  )

//请求删除一条品牌属性的函数
export const ReqDelOneAttrList = (attrId: number) =>
  request.delete(`${Api.delOneAttrListApi}/${attrId}`)

//请求一条品牌属性数据的函数
export const ReqFindOneAttrListData = (attrId: number) =>
  request.get(`${Api.findOneAttrListDataApi}/${attrId}`)

//请求添加品牌属性数据的函数
export const ReqAddAttrListData = (data: any) => {
  request.post(`${Api.addAttrListData}`, data)
}
